export function searchColumns() {
  return [
    {
      filterable: true,
      prop: 'searchUid',
      type: 'select',
      dicData: this.userList,
      props: {
        label: 'Name',
        value: 'Uid',
      },
      placeholder: '请选择操作人',
    },
    {
      filterable: true,
      prop: 'searchPath',
      type: 'select',
      props: {
        label: 'Title',
        value: 'name',
      },
      placeholder: '请选择资源路径',
    },
    {
      prop: 'daterange',
      type: 'daterange',
    },
  ]
}

export function tableColumns() {
  const formatPath = (row, routerMap) => {
    const pathArr = row?.Path?.substr(1).split('/')
    const [parentPath, childPath, action] = pathArr
    const actionKey = action?.split('_')[0]
    const parentPathTitle = routerMap[parentPath]?.meta?.title
    const childPathTitle = routerMap[childPath]?.meta?.title
    return {
      module: `${this.$t(`${parentPathTitle}`)}/${this.$t(`${childPathTitle}`)}`,
      perm: this.$t(`permissions.${actionKey || 'unkown'}`),
    }
  }

  return [
    {
      label: '序号',
      prop: 'Id',
      width: 80,
    },
    {
      label: '操作人',
      prop: 'Uid',
      // formatter: row => this.userArray.find(item => item?.Uid === row?.Uid)?.Name ?? '--',
    },
    {
      label: '操作模块',
      prop: 'Path',
      overHidden: true,
      formatter: row => formatPath(row, this.routerMap).module,
    },
    {
      label: '权限',
      prop: 'Path',
      formatter: row => formatPath(row, this.routerMap).perm,
    },
    {
      label: 'IP',
      prop: 'IP',
    },
    {
      label: '浏览器信息',
      overHidden: true,
      prop: 'UA',
    },
    {
      label: '操作时间',
      prop: 'CreateTime',
      formatter: row => this.$formatTime(row?.CreateTime),
    },
  ]
}
